﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//继承自这种单例模式基类 需要手动或API添加脚本到场景挂载
/// <summary>
/// 单例模式基础父级
/// </summary>
/// <typeparam name="T">子集的名称</typeparam>
public class 单例_基础可挂载管理器<T> : MonoBehaviour where T : MonoBehaviour
{
    private static T 实例;
    public static T 获取实例 => 实例;

    protected virtual void Awake()
    {
        if (实例 == null)
        {
            实例 = this as T;
            DontDestroyOnLoad(gameObject);
        }
        else
            Destroy(this);
    }

}

